package org.study.redisson.boot.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.study.redisson.boot.model.User;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2024年01月19日
 */
@Slf4j
@Component
public class CacheService {
    @Cacheable(value = "userCache", key = "#userId", cacheManager = "cacheManager")
    public User queryById(Long userId) {
        log.info("从数据库中查询 id={} 的用户信息", userId);
        User user = new User();
        user.setUserId(userId);
        user.setUsername("用户名-" + userId);
        user.setPhone("15211223344");
        return user;
    }
}
